package com.wj.jiangan.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wj.jiangan.pojo.vo.inproductProductEmpVo;
import com.wj.jiangan.service.IInproductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wj
 * @since 2019-11-05
 */
@RestController
@RequestMapping("/inproduct")
public class InproductController {

    @Autowired
    private IInproductService inproductService;

    //查询入库商品的信息
    @GetMapping("ipe")
    public Map<String, Object> findipeVopage(Page page, @RequestParam(required = false) Integer pid) {
        Map<String, Object> maps = new HashMap<>();
        maps.put("pid", pid);
        IPage<inproductProductEmpVo> inpducemp = inproductService.finAllipeVoinfo(page, maps);
        List<Map<String, Object>> list = new ArrayList<>();
        inpducemp.getRecords().forEach(o -> {
            Map<String, Object> map = new HashMap<>();
            map.put("pid", o.getInproduct().getPId());
            map.put("pname", o.getProduct().getPName());
            map.put("etruename", o.getEmp().getETruename());
            map.put("dremark", o.getInproduct().getDRemark());
            map.put("dint", o.getInproduct().getDInt());
            map.put("dtime", o.getInproduct().getDTime());
            list.add(map);
        });
        Map<String, Object> result = new HashMap<>();
        result.put("code", 0);
        result.put("count", inpducemp.getTotal());
        result.put("data", list);
        return result;
    }


}
